program drop _all
program define hurwicz, rclass
version 14
syntax, beta0(real) betay(real) betau(real) smallobs(integer) bigobs(integer)
// Remove existing variables
drop _all

// Create the data
set obs `bigobs' 
gen t = _n
tsset t
// We initialize y as its LR equilibrium value
gen y = `beta0'/(1-`betay')
replace y = `beta0' + `betay'*L.y + `betau'*rnormal() in 2/l
regress y L.y in -`smallobs'/l
return scalar bhaty = _b[L.y]
test _b[L.y] = `betay'
return scalar pvalue = r(p)

end
